package com.zhou;

import java.util.Scanner;

/**
 * T10
 *
 * @author zhouxianfeng
 * @date 2021-8-20
 */
public class T10 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num = in.nextInt();
        in.nextLine();
        String[] pi = in.nextLine().split(" ");

        long[] res = new long[num + 1];
        for (int i = 0; i <= num; i++) {
            if (i == 0) {
                res[0] = 0;
            } else {
                res[i] = Math.floorMod((2 * res[i - 1] - res[Integer.parseInt(pi[i - 1]) - 1] + 2), 1000000007);
            }
        }
        System.out.println(res[num]);
//        if (res[num] < 0) {
//            System.out.println(res[num] + 1000000007);
//        } else {
//
//        }


    }
}
